<template>
	<!--pages/store/home/home.wxml-->
	<view class="container">
		<!-- banner -->
		<view class="margin">
			<view class="banner">
				<image :src="storeInfo.store_pic" mode="aspectFill"></image>
			</view>
		</view>

		<!-- 店铺名称 -->
		<view class="row store-name bottom-line margin">
			<text class="name">{{storeInfo.store_name}}</text>
			<view class="row collect auto-left" @click.stop="collect" >
				<image :src="'/static/imgs/collect-active.png'" v-if="storeInfo.my_is_col==1"></image>
				<image :src="'/static/imgs/collect.png'" v-else> </image>
				<text>喜欢这家店</text>
			</view>
		</view>
		<!-- 营业时间 -->
		<view class="col opening bottom-line margin">
			<view class="row header">
				<image :src="url+'/static/imgs/store.png'"></image>
				<view class="text">
					<text>{{storeInfo.status==1?'营业中':'休息中'}}</text>
					<text> | {{storeInfo.start_time}}-{{storeInfo.end_time}}</text>
				</view>
			</view>
			<view class="row tags">
				<text v-for="(item,index) in storeInfo.tags" v-bind:key="index">{{item}}</text>
			</view>
		</view>
		<!-- 位置 -->
		<view class="row address bottom-line margin">
			<view class="col address-info">
				<text class="text-ellipsis">{{storeInfo.map_address}}</text>
			</view>
			<view class="icon-group row">
				<image :src="url+'/static/imgs/loaction.png'" class="loaction" @click="openLocation"></image>
				<image :src="url+'/static/imgs/tel.png'" class="tel" @click="makePhoneCall"></image>
			</view>
		</view>
		<!-- 店长的话 -->
		<view class="col content margin">
			<image :src="url+'/static/imgs/hua.png'"></image>
			<view class="word">{{storeInfo.remark}}</view>
		</view>
	</view>
</template>

<script>
	var app = getApp();
	import http from '../../../common/js/request.js'
	export default {
		data() {
			return {
				store_id: app.globalData.storeId,
				url: app.globalData.baseImgUrl,
				storeInfo: [],
			}
		},
		onLoad() {
			console.log('storeId', app.globalData.storeId)
			this.getStoreInfo();
		},
		methods: {
			//店铺详情
			getStoreInfo() {
				var that = this;
				http.post('/api/v1/store/store_detail', {
					store_id: that.store_id
				}, res => {
					that.storeInfo = res.datas;
				});
			},
			//收藏/取消收藏店铺
			collect() {
				var that = this;
				http.post('/api/v1/store/make_col', {
					store_id: that.store_id
				}, res => {
					if (res.state == 1) {
						uni.showToast({
							title: that.storeInfo.my_is_col == 0 ? '已收藏~' : '已取消收藏~',
							icon: 'none'
						});
						that.storeInfo.my_is_col = that.storeInfo.my_is_col == 1 ? 0 : 1;
					}

				});
			},
			//地图查看
			openLocation() {
				var that = this;
				uni.openLocation({
					latitude: Number(that.storeInfo.latitude),
					longitude: Number(that.storeInfo.longitude),
					name: that.storeInfo.store_name
				})
			},
			//拨打电话
			makePhoneCall() {
				var that = this;
				uni.makePhoneCall({
					phoneNumber: that.storeInfo.mobile
				})
			},
		}
	}
</script>

<style>
	@import url("../../../common/css/store-info.css");

	.content {
		align-items: center;
		justify-content: center;
		font-size: 28rpx;
		color: #333333;
	}

	.content image {
		margin: 50rpx 0rpx;
		width: 90rpx;
		height: 90rpx;
	}
</style>
